Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new
interrupt()
method:This method causes any pending database operation to abort and return at its earliest opportunity.
It can be called from any thread.
A call to
interrupt()
that occurs when there are no running SQL statements is a no-op and has no effect on SQL statements that are started afterinterrupt()
returns.A database operation that is interrupted will throw a DatabaseError with code SQLITE_INTERRUPT. If the interrupted SQL operation is an INSERT, UPDATE, or DELETE that is inside an explicit transaction, then the entire transaction will be rolled back automatically. If the rolled back transaction was started by a transaction-wrapping method such as
DatabaseWriter.write
orDatabase.inTransaction
, then all database accesses will throw a DatabaseError with code SQLITE_ABORT until the wrapping method returns.For example:
A DatabaseError of code SQLITE_ABORT is generally thrown when the application accesses the database, inside a transaction-wrapping method, if the transaction was ended prematurely. This may happen due to
interrupt()
, but also, for example, from an ON CONFLICT ROLLBACK clause.When an application creates transaction without a transaction-wrapping method, no SQLITE_ABORT error warns of aborted transactions: